// import com->alibaba->druid->sql->ast->SQLName_ptr ;
// import com->alibaba->druid->sql->visitor->SQLASTVisitor*;

// import java->util->ArrayList;
// import java->util->std::list;

#pragma once

#include <string>
#include <list>

#include "../SQLName.h"
#include "SQLSelect.h"
#include "SQLSelectQuery.h"
#include "SQLTableSourceImpl.h"
#include "../../../utils/common_ptr.h"

class SQLASTVisitor;
class SQLSubqueryTableSource
    : virtual public SQLTableSourceImpl//,
      // virtual public std::enable_shared_from_this<SQLSubqueryTableSource>
{
public:
  static string_ptr class_;
  SQLSelect_ptr select;
  SQLName_list_ptr columns;

  SQLSubqueryTableSource();

  SQLSubqueryTableSource(string_ptr alias);

  SQLSubqueryTableSource(SQLSelect_ptr select, string_ptr alias);

  SQLSubqueryTableSource(SQLSelect_ptr select);

  SQLSubqueryTableSource(SQLSelectQuery_ptr query);

  SQLSubqueryTableSource(SQLSelectQuery_ptr query, string_ptr alias);
  SHAREDOBJECT(SQLSubqueryTableSource);

  SQLSelect_ptr getSelect();

  void setSelect(SQLSelect_ptr x);

  void accept0(SQLASTVisitor_ptr visitor) override;

  void cloneTo(SQLSubqueryTableSource_ptr x);

  // SQLSubqueryTableSource* clone() ;
  virtual SQLObject_ptr clone();

  SQLTableSource_ptr findTableSourceWithColumn(string_ptr columnName);

  SQLTableSource_ptr findTableSourceWithColumn(long columnNameHash, string_ptr columnName, int option);

  bool equals(Object_ptr o);

  int hashCode();

  SQLName_list_ptr getColumns();

  void addColumn(SQLName_ptr column);

  // SQLColumnDefinition* findColumn(long columnNameHash) ;

  virtual SQLColumnDefinition_ptr findColumn(string_ptr columnName) override{};
  virtual SQLColumnDefinition_ptr findColumn(long columnNameHash) override{};
};
